package com.dongnam.quanly.common.dao;

import java.util.List;

import org.hibernate.Query;

import com.dongnam.quanly.common.model.NhomDoiTac;
import com.dongnam.quanly.common.model.PhongBan;

public class PhongBanDao extends ExtendedGenericDao<PhongBan, String> {

	public List<PhongBan> listPhongBanExclude(List<String> listPhongBan) {

		String result = "";

		if (listPhongBan.size() != 0) {
			result = "'" + listPhongBan.get(0) + "'";
			for (int i = 1; i < listPhongBan.size(); i++) {
				result = result + ",'" + listPhongBan.get(i) + "'";
			}
		}

		String queryString = "Select pb from PhongBan pb where pb.maPhongBan not in (" + result + ")";
		Query query = getSession().createQuery(queryString);

		// query.setParameter("listNhomDoiTac", listNhomDoiTac);

		@SuppressWarnings("unchecked")
		List<PhongBan> list = query.list();

		return list;

	}

	public List<PhongBan> listPhongBanInclude(List<String> listPhongBan) {
		String result = "";

		if (listPhongBan.size() != 0) {
			result = "'" + listPhongBan.get(0) + "'";
			for (int i = 1; i < listPhongBan.size(); i++) {
				result = result + ",'" + listPhongBan.get(i) + "'";
			}
		}

		String queryString = "Select pb from PhongBan pb where pb.maPhongBan in (" + result + ")";
		Query query = getSession().createQuery(queryString);

		// query.setParameter("listNhomDoiTac", listNhomDoiTac);

		@SuppressWarnings("unchecked")
		List<PhongBan> list = query.list();

		return list;
	}
}
